<?php
namespace app\api\controller;
use app\common\controller\WechatBase;
use think\facade\Request;
use think\facade\Db;
use think\facade\Cache;
use think\facade\Session;
use app\api\model\Shop as Shanghu;

class Shop extends WechatBase
{
    protected function _initialize()
    {
        parent::_initialize();
        
    }
    //修改商家资料
    public function edit()  
    {
        if ($this->request->isPost()) {
            $param = $this->request->param();
            insert_wechat_log('修改了资料，名字：'.$param['name'].'，电话：'.$param['mobile'].'');
            Shanghu::where('id', ShopId())->strict(false)->update([
                'name'         => $param['name'],
                'mobile'       => $param['mobile'],
                'province'     => $param['province'],
                'city'         => $param['city'],
                'area'         => $param['area'],
                'address'      => $param['address'],
                'update_time'  => time()
            ]);
            $this->result('', '0', '修改成功', 'json');
        }else{
            $shop = Shanghu::where('id', ShopId())->find();
            $region1[0] = $shop['province'];
            $region1[1] = $shop['city'];
            $region1[2] = $shop['area'];
            $data = ['shop' => $shop,'region1'=>$region1,'message'=>Newmessage()];
            $this->result($data, '0', '获取成功', 'json');
        }
    }
    
    
    
    
}
